﻿Public Class fListaZonas
    Private lIdZona As String
    Dim daZona As lbGlobalcom.dsGlobalTableAdapters.GLO_ZONASTableAdapter
    Public ReadOnly Property midZona() As String
        Get
            Return lIdZona
        End Get
    End Property
    Private Sub btnConsulta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsulta.Click
        Try
            daZona = New lbGlobalcom.dsGlobalTableAdapters.GLO_ZONASTableAdapter
            daZona.FillByLikeDescripcion(DsGlobal.GLO_ZONAS, "%" & txtZona.Text & "%")
            GLO_ZONASDataGridView.Focus()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub GLO_ZONASDataGridView_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles GLO_ZONASDataGridView.CellMouseDoubleClick
        If e.RowIndex >= 0 Then
            lIdZona = GLO_ZONASDataGridView.Rows(e.RowIndex).Cells("IdZona").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub AsignaZona(ByVal Fila As Integer)
        If Fila >= 0 Then
            lIdZona = GLO_ZONASDataGridView.Rows(Fila).Cells("IdZona").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub
    
    Private Sub GLO_ZONASDataGridView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GLO_ZONASDataGridView.KeyDown
        If e.KeyData = Keys.Enter Then
            AsignaZona(GLO_ZONASDataGridView.CurrentRow.Index)
        End If
    End Sub
End Class